# syntax=docker/dockerfile:1
FROM golang:1.20-alpine as builder
ARG TARGETOS
ARG TARGETARCH

ENV GOPROXY=https://goproxy.cn/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; \
    apk add --no-cache gcc musl-dev

ARG BUILD_DIR
ENV HTTPS_PROXY=http://100.117.48.13:1080

WORKDIR /app
COPY dplog/go.mod dplog/go.sum ./dplog/
RUN cd ./dplog/ && go mod download && go mod verify
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
	go build -ldflags "-s -w -linkmode external -extldflags '-static'"  \
    -v  \
    -o /app/bin/ gitee.com/yysf_xin/dplog/cmd/dplog3

FROM scratch
ARG TARGETOS
ARG TARGETARCH
ARG BUILD_NAME
VOLUME /app
WORKDIR /app
COPY --from=builder /app/bin/ /bin/
ENTRYPOINT ["/bin/dplog3"]
